﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Puzzler.Plugin.Interface.Exceptions;

namespace Puzzler.Plugin.Interface
{
    /// <summary>
    /// Interface for a plugin upgrate handler. 
    /// Upgrate the XML or Binary File to the current version
    /// </summary>
    public interface IPuzzleIOUpgrateHandler : IPuzzlePluginAction
    {
        /// <summary>
        /// Upgrate the given XML Node from the found version to the current version
        /// </summary>
        /// <param name="element"></param>
        /// <param name="foundVersion">Version that was found in opened file</param>
        /// <param name="currentVersion">Current version of XML file format</param>
        /// <returns>TRUE if upgrate was successfully, FALSE if no upgrate path was found</returns>
        /// <exception cref="PuzzlerPluginIOUpgrateException">Is thrown if there are errors while transformation</exception>
        bool UpgrateXml(XElement element, int foundVersion, int currentVersion);
        /// <summary>
        /// Upgrate the given Binary File from the found version to the current version
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="foundVersion">Version that was found in opened file</param>
        /// <param name="currentVersion">Current version of binary file format</param>
        /// <returns>TRUE if upgrate was successfully, FALSE if no upgrate path was found</returns>
        /// <exception cref="PuzzlerPluginIOUpgrateException">Is thrown if there are errors while transformation</exception>
        bool UpgrateBinary(StreamReader reader, int foundVersion, int currentVersion);
    }
}
